/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modulos.respaldosBD;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import vista.modelo.OperacionesVarias;

/**
 *
 * @author francisco
 */
public class FrmCargarRespaldo extends javax.swing.JInternalFrame {

    /**
     * Creates new form FrmCargarRespaldo
     */
    public FrmCargarRespaldo() {
        initComponents();
        OperacionesVarias.centrar(this);
        filtroSQL = new FileNameExtensionFilter("Archivos SQL", "sql");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        txtUsuario = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        txtDirectorio = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        btnBuscar = new javax.swing.JButton();
        btnCargar = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        txtClave = new javax.swing.JPasswordField();

        setTitle("CARGAR RESPALDO");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/db.png"))); // NOI18N
        getContentPane().setLayout(null);

        jLabel2.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel2.setText("UsuarioBD: ");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(10, 20, 100, 17);
        getContentPane().add(txtUsuario);
        txtUsuario.setBounds(90, 10, 100, 30);

        jLabel1.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel1.setText("ClaveBD: ");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(210, 20, 80, 17);
        getContentPane().add(txtDirectorio);
        txtDirectorio.setBounds(10, 70, 280, 30);

        jLabel3.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel3.setText("Directorio archivo sql:");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(10, 50, 190, 17);

        btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/search.png"))); // NOI18N
        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });
        getContentPane().add(btnBuscar);
        btnBuscar.setBounds(300, 70, 110, 30);

        btnCargar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/refresh.png"))); // NOI18N
        btnCargar.setText("CARGAR");
        btnCargar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCargarActionPerformed(evt);
            }
        });
        getContentPane().add(btnCargar);
        btnCargar.setBounds(80, 120, 110, 30);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/delete.png"))); // NOI18N
        jButton2.setText("CANCELAR");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(210, 120, 120, 30);

        txtClave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtClaveActionPerformed(evt);
            }
        });
        getContentPane().add(txtClave);
        txtClave.setBounds(280, 10, 115, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-431)/2, (screenSize.height-193)/2, 431, 193);
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        JFileChooser jf = new JFileChooser();
        jf.setFileFilter(filtroSQL);
        int opc = jf.showOpenDialog(this);
        if (opc == JFileChooser.APPROVE_OPTION) {
            direccion = jf.getSelectedFile().toString();
            txtDirectorio.setText(direccion);
        }
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnCargarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCargarActionPerformed
        usuario = txtUsuario.getText();
        clave = txtClave.getText();
        FrmGeneracion fg = new FrmGeneracion(direccion, usuario, clave, 2);
        dispose();
    }//GEN-LAST:event_btnCargarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void txtClaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtClaveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtClaveActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnCargar;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPasswordField txtClave;
    private javax.swing.JTextField txtDirectorio;
    private javax.swing.JTextField txtUsuario;
    // End of variables declaration//GEN-END:variables
    FileNameExtensionFilter filtroSQL;
    String direccion;
    String usuario;
    String clave;
}
